package com.whz.bus.consumer;

import org.springframework.context.ApplicationEvent;

import java.util.List;

/**
 * 监听数据库变化的事件,封装了数据库变化的行,需要自己监听这个事件
 */
public class DataBaseChangeRecordEvent extends ApplicationEvent {
    private static final long serialVersionUID = 5960610764510742897L;
    private final List<RelationalChangeData> data;

    /**
     * Create a new {@code ApplicationEvent}.
     *
     * @param source the object on which the event initially occurred or with
     *               which the event is associated (never {@code null})
     */
    public DataBaseChangeRecordEvent(Object source, List<RelationalChangeData> data) {
        super(source);
        this.data = data;
    }

    /**
     * 获取数据库的变化的行
     *
     * @return 数据库的变化的行
     */
    public List<RelationalChangeData> getChangeData() {
        return data;
    }

    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
        throw new java.io.NotSerializableException("tech.tongyu.binlog.bus.consumer.DataBaseChangeRecordEvent");
    }

    private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
        throw new java.io.NotSerializableException("tech.tongyu.binlog.bus.consumer.DataBaseChangeRecordEvent");
    }
}